package com.itdianzi.controller.stat;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itdianzi.controller.base.BaseController;
import com.itdianzi.service.stat.StatService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {
    @Reference
    private StatService statService;

    @RequestMapping("/toCharts")
    public String toCharts(String chartsType) {
        statService.sayHello("wb66666");
        return "stat/stat-"+chartsType;
    }

    /**
     * ajax返回数据
     * [
     *  {value:335, name:'直接访问'},
     *  {value:310, name:'邮件营销'},
     *  {value:234, name:'联盟广告'},
     *  {value:135, name:'视频广告'},
     *  {value:1548, name:'搜索引擎'}
     * ]
     * List<对象>  List<Map>  页面的数据得到
     * @return
     */
    @RequestMapping("/findFactory.do")
    @ResponseBody
    public List<Map> factoryCharts() {
        List<Map> factory = statService.findFactory(super.companyId);


        return factory;
    }
     @RequestMapping("/onlineCharts")
     @ResponseBody
    public List<Map> onlineCharts() {
         List<Map> online = statService.findOnline(super.companyId);

         return online;
     }

    @RequestMapping("/sellCharts")
    @ResponseBody
    public List<Map> sellCharts() {
        List<Map> sell = statService.findSell(super.companyId);

        return sell;
    }

    @RequestMapping("/priceCharts")
    @ResponseBody
    public List<Map> priceCharts() {
        System.out.println(111);
        List<Map> price = statService.findPrice(companyId);
        System.out.println(price);
        System.out.println(111);
        return price;
    }
}
